home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-12-11 | 6.0 KB | 220 lines | [TEXT/MPS ] |
- /*
- File: Palette.h
-
- Contains: Palette Classes Definition
-
- Written by: Dave Stafford
-
- Copyright: © 1995 by Apple Computer, Inc., all rights reserved.
- */
-
- // -- Compiler/Preprocessor Switches --
-
- #ifndef _PALETTE_
- #define _PALETTE_
-
- #ifndef _COMPILERDEFS_
- #include "CompDefs.h"
- #endif
-
- #ifndef _DRAWEDITORDEF_
- #include "DrawEditorDef.h"
- #endif
-
- //=============================================================================
- // Forward Declarations
- //=============================================================================
- class DrawEditor;
-
- //=============================================================================
- // Constants
- //=============================================================================
-
- //=============================================================================
- // Enumerations
- //=============================================================================
-
- enum {
- kSelectionTool = 1,
- kTextTool,
- kRectangleTool,
- kLineShapeTool,
- kOvalTool,
- kPolygonTool,
- kInactiveTextTool
- };
-
- //=============================================================================
- // CRGBColor
- //=============================================================================
- struct CRGBColor {
-
- // -- Construction --
- CRGBColor( unsigned short redColor = 0,
- unsigned short greenColor = 0,
- unsigned short blueColor = 0 )
- { red = redColor; green = greenColor; blue = blueColor; };
-
- CRGBColor(RGBColor& color) { red = color.red; green = color.green; blue = color.blue; };
- CRGBColor(RGBColor* color) { red = color->red; green = color->green; blue = color->blue; };
- CRGBColor(const CRGBColor& color ) { red = color.red; green = color.green; blue = color.blue; };
- CRGBColor& operator=(const RGBColor& rgb);
-
- unsigned short red; /*magnitude of red component*/
- unsigned short green; /*magnitude of green component*/
- unsigned short blue; /*magnitude of blue component*/
- };
-
-
-
- //=============================================================================
- // CPalette
- //=============================================================================
- class CPalette
- {
- public:
-
- // -- Init --
- CPalette(DrawEditor* part);
-
- // Clients should call ClosePalette instead of destructing directly.
- protected:
- virtual ~CPalette();
-
- public:
-
- // -- Accessors --
- virtual ODSShort GetSelectedPaletteItem() const;
- virtual void SetSelectedPaletteItem(ODSShort paletteItem);
-
- // -- Palette --
- virtual void GetPaletteRect(Rect* r) = 0;
- virtual void TokenizePalettePresentation(Environment* ev, ODSession* session) = 0;
- virtual void Draw(Environment* ev, ODFacet* facet, ODShape* invalidShape) = 0;
- virtual ODBoolean DoMouseDownInPalette(Environment* ev,
- ODFrame* frame,
- Point where,
- ODSShort* chosenItem,
- ODBoolean changePalette) = 0;
-
- // -- Window --
- virtual void CreatePalette(Environment* ev);
- void ClosePalette(Environment* ev);
- void ShowPalette(Environment* ev, ODBoolean show);
- ODBoolean IsShown(Environment* ev);
-
- // -- Presentation --
- ODTypeToken GetPresentation() const;
- void SetPresentation(ODTypeToken presentation);
-
- protected:
-
- // -- Window --
- ODWindow* GetPaletteWindow(Environment* ev);
-
- //----------------------------------------------------------------------------------------
- // Data Members
- //
- protected:
-
- ODSShort fSelectedPaletteItem;
- DrawEditor* fDrawEditor;
- ODTypeToken fPresentation;
- ODID fODWindowID;
- };
-
-
- //=============================================================================
- // CColorPalette
- //=============================================================================
-
- class CColorPalette : public CPalette
- {
- public:
-
- // -- Init --
- CColorPalette(DrawEditor* part);
- virtual ~CColorPalette();
-
- public:
-
- // -- Palette --
- void GetColor(short colorIndex, CRGBColor* color) const;
- ODSShort NumberOfColors() const;
-
- void GetPaletteRect(Rect* r);
- void TokenizePalettePresentation(Environment* ev, ODSession* session);
-
- virtual void Draw(Environment* ev, ODFacet* facet, ODShape* invalidShape);
-
- virtual ODBoolean DoMouseDownInPalette(Environment* ev,
- ODFrame* frame,
- Point where,
- ODSShort* chosenItem = kODNULL,
- ODBoolean changePalette = kODTrue);
-
- //----------------------------------------------------------------------------------------
- // Data Members
- //
- private:
- static const short kColorPaletteHeight;
- static const short kColorPaletteWidth;
- static const short kColorSwatchSize;
- static const short kColorSwatchAreaOffset;
-
- short fNumbersOfColors;
- ODRect fSavedInvalidRect;
- CTabHandle fColorTable;
- };
-
-
- //=============================================================================
- // CToolPalette
- //=============================================================================
-
- class CToolPalette : public CPalette
- {
- public:
-
- // -- Init --
- CToolPalette(DrawEditor* part);
- virtual ~CToolPalette();
-
- public:
-
- // -- Palette --
- virtual void CreatePalette(Environment* ev);
-
- void GetToolRect(short tool, Rect* rect);
- void AdjustTextTool(Environment* ev);
-
- virtual void ActivateTool(Environment* ev, ODSShort whichTool);
- virtual void InvalidateTool(Environment* ev, ODSShort whichTool);
- virtual ODBoolean DoMouseDownInPalette(Environment* ev,
- ODFrame* frame,
- Point where,
- ODSShort* chosenItem = kODNULL,
- ODBoolean changePalette = kODTrue);
- virtual void Draw(Environment* ev, ODFacet* facet, ODShape* invalidShape);
-
- void GetPaletteRect(Rect* r);
- void TokenizePalettePresentation(Environment* ev, ODSession* session);
-
-
- //----------------------------------------------------------------------------------------
- // Data Members
- //
- private:
- static const short kToolPaletteHeight;
- static const short kToolPaletteWidth;
- static const short kPaletteBasePictureID;
- static const short kToolCount;
- static const short kToolSize;
- static const short kToolOffset;
-
- ODBoolean fTextToolActive;
- PicHandle* fToolPicts;
- };
-
-
- #endif